package com.shrct.businessprocess.purchase.impl;

import com.shrct.businessprocess.project.RCProjectMoney;
import com.shrct.businessprocess.purchase.RCBasePurchaseOrderAccept;
import com.shrct.businessprocess.purchase.RCPurchaseOrderPayProcess;
import com.shrct.businessprocess.purchase.RCPurchaseOrderPayProcessItem;
import com.shrct.businessprocess.purchase.impl.RCBasePurchaseOrderAcceptImpl;
import com.shrct.businessprocess.purchase.impl.RCPurchaseOrderPayProcessImpl;
import com.shrct.businessprocess.purchase.proxy.RCPurchaseOrderPayProcessItemProxy;
import edu.fudan.mylang.pf.BaseModelObject;
import edu.fudan.mylang.pf.IObjectFactory;
import java.util.Date;
import javax.persistence.AssociationOverride;
import javax.persistence.AssociationOverrides;
import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
import org.hibernate.annotations.DiscriminatorOptions;

@Entity
@DiscriminatorValue("RCPURCHASEORDERPAYPROCESSITEM_TYPE")
@DiscriminatorOptions(force = true)
@DiscriminatorColumn(length = 64)
@Table(name = "rcpurchaseorderpayprocessitem")
public class RCPurchaseOrderPayProcessItemImpl extends BaseModelObject implements RCPurchaseOrderPayProcessItem {
  public RCPurchaseOrderPayProcessItemImpl() {
    super();
  }
  
  public RCPurchaseOrderPayProcessItemImpl(final RCPurchaseOrderPayProcess payProcess) {
    super();
    this.payProcess = payProcess;
  }
  
  @JoinColumn(name = "accept_id")
  @ManyToOne(targetEntity = RCBasePurchaseOrderAcceptImpl.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST })
  private RCBasePurchaseOrderAccept accept;
  
  public RCBasePurchaseOrderAccept getAccept() {
    return this.accept;
  }
  
  public RCPurchaseOrderPayProcessItem setAccept(final RCBasePurchaseOrderAccept accept) {
    this.accept = accept;
    return this;			
    
  }
  
  @JoinColumn(name = "payProcess_id")
  @ManyToOne(targetEntity = RCPurchaseOrderPayProcessImpl.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST })
  private RCPurchaseOrderPayProcess payProcess;
  
  public RCPurchaseOrderPayProcess getPayProcess() {
    return this.payProcess;
  }
  
  public RCPurchaseOrderPayProcessItem setPayProcess(final RCPurchaseOrderPayProcess payProcess) {
    this.payProcess = payProcess;
    return this;			
    
  }
  
  private Date date;
  
  public Date getDate() {
    return this.date;
  }
  
  public RCPurchaseOrderPayProcessItem setDate(final Date date) {
    this.date = date;
    return this;			
    
  }
  
  @Embedded
  @AttributeOverrides(value = { @AttributeOverride(name = "amount", column = @Column(name = "amount_amount") ), @AttributeOverride(name = "workaround", column = @Column(name = "amount_workaround") ) } )
  @AssociationOverrides(value = @AssociationOverride(name = "exchange", joinColumns = @JoinColumn(name = "amount_exchange") ) )
  private RCProjectMoney amount = com.shrct.businessprocess.project.RCProjectMoney.create();
  
  public RCProjectMoney getAmount() {
    return this.amount;
  }
  
  public RCPurchaseOrderPayProcessItem setAmount(final RCProjectMoney amount) {
    this.amount = amount;
    return this;			
    
  }
  
  public static RCPurchaseOrderPayProcessItem create(final RCPurchaseOrderPayProcess payProcess, final IObjectFactory objectFactory) {
    com.shrct.businessprocess.purchase.RCPurchaseOrderPayProcessItem rCPurchaseOrderPayProcessItem = new com.shrct.businessprocess.purchase.impl.RCPurchaseOrderPayProcessItemImpl(
    	payProcess
    );
    objectFactory.create(rCPurchaseOrderPayProcessItem);
    return rCPurchaseOrderPayProcessItem;			
    
  }
  
  public static RCPurchaseOrderPayProcessItem createRCPurchaseOrderPayProcessItemImpl(final RCPurchaseOrderPayProcess payProcess, final IObjectFactory objectFactory, final Procedure1<RCPurchaseOrderPayProcessItem> init) {
    com.shrct.businessprocess.purchase.RCPurchaseOrderPayProcessItem rCPurchaseOrderPayProcessItem = new com.shrct.businessprocess.purchase.impl.RCPurchaseOrderPayProcessItemImpl(
    	payProcess
    );
    objectFactory.create(rCPurchaseOrderPayProcessItem);
    init.apply(rCPurchaseOrderPayProcessItem);
    
    return rCPurchaseOrderPayProcessItem;			
    
  }
  
  public RCPurchaseOrderPayProcessItemProxy toProxy() {
    com.shrct.businessprocess.purchase.proxy.RCPurchaseOrderPayProcessItemProxy proxy = new com.shrct.businessprocess.purchase.proxy.RCPurchaseOrderPayProcessItemProxy();
    proxy.setId(this.getId());
    if(this instanceof edu.fudan.mylang.pf.INamedModelObject){
    	proxy.setName(((edu.fudan.mylang.pf.INamedModelObject)this).getEntityName());
    }
    return proxy;
    
  }
}
